<?
	$_SESSION['url'] = getURL();
	if($_SESSION['is_login'] != true){
		header("Location: ".$root."/dang-nhap/");
	}
	
	if(isset($_GET['tid'])){$tid = intval($_GET['tid']);}else{reHome($urlHome);}
	
	
	
	
	$rs = $db->query("SELECT * FROM ".$prefix."tuyendung WHERE td_id = '".$tid."' AND td_hienthi = 1");
	$row = $db->fetch_array($rs);
	
	$td_id = $row[td_id];
	$td_loaituyendung = $row[td_loaituyendung];
	$td_tieude = $myString->unQuote(stripslashes($row[td_tieude]));
	$td_mota = $myString->unQuote(stripslashes($row[td_mota]));
	$td_maso = $row[td_maso];
	$td_anhthehien = $PathFile . $row[td_anhthehien];
	$td_mucluong = $row[td_mucluong];
	$td_mucluong_from = $row[td_mucluong_from];
	$td_mucluong_to = $row[td_mucluong_to];
	$td_loaitien = loadLoaiTien($row[td_loaitien]);
	$td_nguoidang = $row[td_nguoidang];
	$td_ten_nguoidang = tenNguoiDung($td_nguoidang);
	$td_ngaydang = format_date($row[td_ngaydang]);
	$td_thoigiandang = $row[td_thoigiandang];
	$td_quocgia = $row[td_quocgia];
	$td_tinhthanh = $row[td_tinhthanh];
	$td_loaihinhcongviec = $row[td_loaihinhcongviec];
	$td_capbac = $row[td_capbac];
	$td_sonamkinhnghiem =  $row[td_sonamkinhnghiem];
	$td_capbactoithieu = $row[td_capbactoithieu];
	$td_bangcaptoithieu = $row[td_bangcaptoithieu];
	$td_ngoaingu = $myString->unQuote(stripslashes($row[td_ngoaingu]));
	$td_tailieuguikem = $PathFileDoc . $row[td_tailieuguikem];
	$td_chitiet = $myString->unQuote(stripslashes($row[td_chitiet]));
	$td_solanxem = $row[td_solanxem];
	$td_xemgannhat = format_date_time($row[td_xemgannhat]); 
	$td_trangthai = $row[td_trangthai];
	$td_hienthi = $row[td_hienthi];
	
	
	if( isset($_GET['act']) && ($_GET['act'] == 'xoa') ) {
		$db->query("UPDATE ".$prefix."tuyendung SET td_anhthehien = '' WHERE td_id = '".$tid."'");
		header("Location: ".$root."/sua-tin-tuyen-dung/".$tid."/".$myString->vietdecoe($td_tieude)."");
	}


	if(isset($_POST['submit'])){
		$td_trangthai = $_POST['td_trangthai'];
		$td_tieude = addslashes($_POST['td_tieude']);
		$td_maso = $_POST['td_maso'];
		$td_mota = addslashes($_POST['td_mota']);
		$td_loaituyendung = $_POST['td_loaituyendung'];
		//Hinhanh
		$DuongDanAnh_tmp = $upload->upload_file($PathFile,'td_anhthehien');
		
		if($DuongDanAnh_tmp != ''){
			$filetype = $upload->file_type($DuongDanAnh_tmp);
			$upload->crop_image($imgWidth,$imgHeight,$PathFile . $DuongDanAnh_tmp,$filetype,$PathThumbFile .$DuongDanAnh_tmp);
			$DuongDanAnh = "'" . $DuongDanAnh_tmp . "'";
		}else{
			$DuongDanAnh = "`td_anhthehien`";
		}
		//
		$td_mucluong = $_POST['td_mucluong'];
		if($td_mucluong == 0){
			$td_mucluong_from = $_POST['td_mucluong_from'];
			$td_mucluong_to = $_POST['td_mucluong_to'];
		}else{
			$td_mucluong_from = 0;
			$td_mucluong_to = 0;
		}
		$td_loaitien = $_POST['td_loaitien'];
		$td_nguoidang = $_SESSION['uid'];
		$td_thoigiandang = addslashes($_POST['td_thoigiandang']);
		$txtQuocGia = $_POST['txtQuocGia'];
		$txtTinhThanh = $_POST['txtTinhThanh'];
		$td_loaihinhcongviec = $_POST['td_loaihinhcongviec'];
		$td_capbac = $_POST['td_capbac'];
		$td_sonamkinhnghiem = addslashes($_POST['td_sonamkinhnghiem']);
		$td_capbactoithieu = $_POST['td_capbactoithieu'];
		$td_bangcaptoithieu = $_POST['td_bangcaptoithieu'];
		$td_ngoaingu = addslashes($_POST['td_ngoaingu']);
		//Tai Lieu dinh kem
		
		$DuongDanAnh_tmp = $upload->upload_file($PathFileDoc,'td_tailieuguikem');
		if($DuongDanAnh_tmp != ''){
			$td_tailieuguikem = "'" . $DuongDanAnh_tmp . "'";
		}else{
			$td_tailieuguikem = "`td_tailieuguikem`";
		}
		
		//
		$td_chitiet = addslashes($_POST['td_chitiet']);
		
		$update = "UPDATE `vstar_tuyendung` SET `td_loaituyendung` = '".$td_loaituyendung."', `td_tieude` = '".$td_tieude."', `td_mota` = '".$td_mota."', `td_maso` = '".$td_maso."', `td_anhthehien` = $DuongDanAnh, `td_mucluong` = '".$td_mucluong."', `td_mucluong_from` = '".$td_mucluong_from."', `td_mucluong_to` = '".$td_mucluong_to."', `td_loaitien` = '".$td_loaitien."', `td_nguoidang` = '".$td_nguoidang."', `td_ngaydang` = '".$td_ngaydang."', `td_thoigiandang` = '".$td_thoigiandang."', `td_quocgia` = '".$txtQuocGia."', `td_tinhthanh` = '".$txtTinhThanh."', `td_loaihinhcongviec` = '".$td_loaihinhcongviec."', `td_capbac` = '".$td_capbac."', `td_sonamkinhnghiem` = '".$td_sonamkinhnghiem."', `td_capbactoithieu` = '".$td_capbactoithieu."', `td_bangcaptoithieu` = '".$td_bangcaptoithieu."', `td_ngoaingu` = '".$td_ngoaingu."', `td_tailieuguikem` = $td_tailieuguikem, `td_chitiet` = '".$td_chitiet."', `td_trangthai` = '".$td_trangthai."' WHERE td_id = '".$tid."'";
		
		//echo $update;
	
		$db->query($update);
		//Lay Id
		header("Location: ".$root."/sua-tin-tuyen-dung/".$tid."/".$myString->vietdecoe($td_tieude).""); 
	}
?>
<div id="linkPath">
       
<script language="javascript" type="text/javascript">
    function CheckVND()
    {
        if(document.getElementById("chkVND").checked==true)
        {
            document.getElementById("btnSave").style.display='';
            document.getElementById("btnSave_off").style.display='none';
        }
        else
        {
            document.getElementById("btnSave").style.display='none';
            document.getElementById("btnSave_off").style.display='';
        }
    }
</script>


<div class="linkPath">
    <div class="corner-round-01-top-right">
        <div class="corner-round-01-top-left">
            <div class="corner-round-01-top-bg"></div>
        </div>

    </div>
    <div class="corner-round-01-body">    
        <span style="float: left;"><a href="?">Trang chủ</a> &raquo; Sửa tin tuyển dụng</span>
        <span style="float: right;"><a title="Quay lại trang trước" class="link-back" href="javascript:void(0);" onclick="javascript:history.go(-1);">Quay lại</a></span>
        <div style="clear: both;"></div>
    </div>
    <div class="corner-round-01-bottom-right">

        <div class="corner-round-01-bottom-left">
            <div class="corner-round-01-bottom-bg"></div>
        </div>
    </div>   
</div>    
    </div>

<form action="" name="frmTuyenDung" id="frmTuyenDung" method="post" enctype="multipart/form-data" onsubmit="return funTuyenDungChecker();">
    <!-- Main Page-Content { -->    
    <div id="page-content">                            
        
<div id="product-new">
    <div class="corner-round-02-top-right">

        <div class="corner-round-02-top-left">
            <div class="corner-round-02-top-bg"></div>
        </div>
    </div>
    <div class="corner-round-02-body" style="height:auto;overflow:hidden">            
        <div id="error" class="form-error-group" style="none: block;width:816px">            
        </div>
        <div class="product-new-inner">            
            <div class="product-top-right"><div class="product-top-left"><div class="product-top-bg"></div></div></div>
            <div class="product-body">                    
                1. Thông tin tuyển dụng <span style="font-size:8pt;color:Gray;font-weight:normal;">(<em>Vui lòng dùng tiếng Việt có dấu hoặc tiếng Anh, độ dài 40 ký tự</em>)</span>

            </div>
            <div class="product-bottom-right"><div class="product-bottom-left"><div class="product-bottom-bg"></div></div></div>
			
			<div style="margin-left:0px;text-align:left;margin-bottom:5px;margin-left:80px;margin-top:10px;font-size:10pt;">                
                <span class="notes" style="color:#666666;font-size:8pt;">
                    Kiểu tuyển dụng :
                </span>
            </div>
            <div style="text-align:left;font-size:10pt;margin-bottom:10px;margin-left:80px;"> 
                <select name="td_trangthai" id="td_trangthai" class="product-input-text">
					<option value="0" <? if($td_trangthai == 0){?> selected="selected" <? } ?>>Việc tìm người</option>
					<option value="1" <? if($td_trangthai == 1){?> selected="selected" <? } ?>>Người tìm việc</option>
				</select>
            </div>
			
			<div style="margin-left:0px;text-align:left;margin-bottom:5px;margin-left:80px;margin-top:10px;font-size:10pt;">                
                <span class="notes" style="color:#666666;font-size:8pt;">
                    Tiêu đề :
                </span>
            </div>
            <div style="text-align:left;font-size:10pt;margin-bottom:10px;margin-left:80px;"> 
                <input class="product-input-text" type="text" style="padding:3px;" id="td_tieude" name="td_tieude" value="<?=$td_tieude?>"/>
            </div>
                
			
			<div style="margin-left:0px;text-align:left;margin-bottom:5px;margin-left:80px;margin-top:10px;font-size:10pt;">                
                <span class="notes" style="color:#666666;font-size:8pt;">
                    Mã số :
                </span>
            </div>
            <div style="text-align:left;font-size:10pt;margin-bottom:10px;margin-left:80px;"> 
                <input class="product-input-text" type="text" style="padding:3px;" id="td_maso" name="td_maso" value="<?=$td_maso?>"/>
            </div>
			
				
           <div style="margin-left:0px;text-align:left;margin-bottom:5px;margin-left:80px;margin-top:10px;font-size:10pt;">                
                <span class="notes" style="color:#666666;font-size:8pt;">
                    Mô tả ngắn :
                </span>
            </div>

            <div style="text-align:left;font-size:10pt;margin-bottom:10px;margin-left:80px;">  
                <input class="product-input-text2" type="text" id="td_mota" name="td_mota" value="<?=$td_mota?>" maxlength="300" />
            </div> 
			
			
			<div style="margin-left:0px;text-align:left;margin-bottom:5px;margin-left:80px;margin-top:10px;font-size:10pt;">                
                <span class="notes" style="color:#666666;font-size:8pt;">
                    Ngành nghề :
                </span>
            </div>

            <div style="text-align:left;font-size:10pt;margin-bottom:10px;margin-left:80px;">  
                <select style="margin:0" class="product-input-select" name="td_loaituyendung" id="td_loaituyendung">           
                    <option value=""></option>
				<?
					$rs = $db->query("SELECT * FROM ".$prefix."loaituyendung WHERE ltd_hienthi = 1 AND ltd_id_cha = 0");
					while($row = $db->fetch_array($rs)){
					$c_ten = $myString->unQuote(stripslashes($row[ltd_ten]));
					$c_id = $row[ltd_id];
				?>	
                    <optgroup label="<?=$c_ten?>">
					<?
						$rs2 = $db->query("SELECT * FROM ".$prefix."loaituyendung WHERE ltd_hienthi = 1 AND ltd_id_cha = '".$c_id."'");
						while($row2 = $db->fetch_array($rs2)){
						$c_id2 = $row2[ltd_id];
						$c_ten2 = $row2[ltd_ten];
					?>
						<option value="<?=$c_id2?>" <? if($td_loaituyendung == $c_id2){?> selected="selected" <? }?>><?=$c_ten2?></option>
					<? } ?>
					</optgroup>
				<? } ?>
                </select>
            </div> 
			
            
            
              
            <br class="clearBoth"/>  
            <div style="height:15px;font-size:0px;"></div>      
            <div class="product-top-right"><div class="product-top-left"><div class="product-top-bg"></div></div></div>
            <div class="product-body">                    
                4. Chi tiết tuyển dụng <span style="font-size:8pt;color:Gray;font-weight:normal;">(<em>Vui lòng dùng tiếng Việt có dấu hoặc tiếng Anh</em>)</span>
				
            </div>
            <div class="product-bottom-right"><div class="product-bottom-left"><div class="product-bottom-bg"></div></div></div>        
			<div class="product-new-control">            
                <div style="margin-left:50px;">                    
                    <p>
                        <label class="title">Ảnh thể hiện</label>

                        <span id="fileDiv">
                            <input name="td_anhthehien" id="td_anhthehien" type="file" class="file" accept="image/gif, image/jpeg, image/jpg" size="73" style="width: 300px;"/><br />                            
                        </span>
                    </p>
					<p>
						<label class="title">&nbsp;</label>
						<span><img src="<?=$root?>/<?=$td_anhthehien?>" border="0" width="120" onerror="this.src='<?=$root?>/themes/images/noimg.jpg';"/>&nbsp;<a href="?mod=suatintuyendung&tid=<?=$td_id?>&act=xoa" style="font-weight:bold; text-decoration:none;">[ Xóa Hình ]</a>
					</p>
					<br style="line-height:5px;"/>
                    <p>

                        <label class="title">&nbsp;</label>
                        <span class="notes" style="color:#666666;font-size:0.8em;">
                            Hỗ trợ file hình định dạng *.jpg, *.gif, *.png. Dung lượng file hình tối đa 1Mb.
                        </span>
                        <br class="clearBoth"/> 
                    </p>                    
                    <p>
                        <label class="title">Thời gian đăng</label>
						<input type="text" name="td_thoigiandang" id="td_thoigiandang" value="<?=$td_thoigiandang?>" style="width: 300px;"/> ngày

                    </p>
					<br style="line-height:5px;"/>
					<p>
                        <label class="title">Mức lương</label>
						<select name="td_mucluong" id="td_mucluong" style="width: 300px;">
							<?
								for($i=0;$i<count($arrMucLuong);$i++){
							?>
								<option value="<?=$i?>" <? if($td_mucluong == $i){ ?> selected="selected" <? }?>><?=$arrMucLuong[$i]?></option>
							<? } ?>
						</select>
                    </p>
					<br style="line-height:5px;"/>
					<p>
						<label class="title">&nbsp;</label>
						Từ : <input type="text" name="td_mucluong_from" id="td_mucluong_from" value="<?=$td_mucluong_from?>" style="width: 60px;" />
						Đến : <input type="text" name="td_mucluong_to" id="td_mucluong_to" value="<?=$td_mucluong_to?>" style="width: 60px;" />
						<select name="td_loaitien" id="td_loaitien" style="width: 90px;">
							<?
								for($i=0;$i<count($arrLoaiTien);$i++){
							?>
							<option value="<?=$i?>" <? if($td_loaitien == $i){ ?> selected="selected" <? }?>><?=$arrLoaiTien[$i]?></option>
							<? }?>
						</select>
					</p>
					<br style="line-height:5px;"/>
					<p>
                        <label class="title">Cấp bậc</label>
						<select name="td_capbac" id="td_capbac" style="width: 300px;">
							<?
								for($i=0;$i<count($arrCapBac);$i++){
							?>
								<option value="<?=$i?>" <? if($td_capbac == $i){ ?> selected="selected" <? }?>><?=$arrCapBac[$i]?></option>
							<? } ?>
						</select>
                    </p>
					<br style="line-height:5px;"/>
					<p>
                        <label class="title">Loại hình công việc</label>
						<select name="td_loaihinhcongviec" id="td_loaihinhcongviec" style="width: 300px;">
							<?
								for($i=0;$i<count($arrLoaiHinhCongViec);$i++){
							?>
								<option value="<?=$i?>" <? if($td_loaihinhcongviec == $i){ ?> selected="selected" <? }?>><?=$arrLoaiHinhCongViec[$i]?></option>
							<? } ?>
						</select>
                    </p>
					<br style="line-height:5px;"/>
					
					<p>
                        <label class="title">Số năm kinh nghiệm</label>
						<input type="text" name="td_sonamkinhnghiem" id="td_sonamkinhnghiem" value="<?=$td_sonamkinhnghiem?>" style="width: 300px;" /> năm
                    </p>
					<br style="line-height:5px;"/>
					
					<p>
                        <label class="title">Cấp bậc tối thiểu</label>
						<select name="td_capbactoithieu" id="td_capbactoithieu" style="width: 300px;">
							<?
								for($i=0;$i<count($arrCapBac);$i++){
							?>
								<option value="<?=$i?>" <? if($td_capbactoithieu == $i){ ?> selected="selected" <? } ?>><?=$arrCapBac[$i]?></option>
							<? } ?>
						</select>
                    </p>
					<br style="line-height:5px;"/>
					
					<p>
                        <label class="title">Bằng cấp tối thiểu</label>
						<select name="td_bangcaptoithieu" id="td_bangcaptoithieu" style="width: 300px;">
							<?
								for($i=0;$i<count($arrBangCap);$i++){
							?>
								<option value="<?=$i?>" <? if($td_bangcaptoithieu == $i){ ?> selected="selected" <? } ?>><?=$arrBangCap[$i]?></option>
							<? } ?>
						</select>
                    </p>
					
					<br style="line-height:5px;"/>
					
					<p>
                        <label class="title">Ngoại ngữ</label>
						<input type="text" name="td_ngoaingu" id="td_ngoaingu" value="<?=$td_ngoaingu?>" style="width: 300px;" /> (Nhập các ngôn ngữ bạn có thể sử dụng)
                    </p>
					<br style="line-height:5px;"/>
					<p>
                        <label class="title">Tài liệu đính kèm</label>

                        <span id="fileDiv">
                            <input name="td_tailieuguikem" id="td_tailieuguikem" type="file" class="file" size="73" style="width: 300px;"/><br />                            
                        </span>
                    </p> 
					<p>
						<label class="title">&nbsp;</label>
						<span>
						<?
							if($td_tailieuguikem != ""){
						?>
						<a target="_blank" href="<?=$td_tailieuguikem?>" style="text-decoration:none;"><img src="<?=$root?>/themes/images/icon/download.gif" border="0" /> tải về </a>
						<? }else{ echo "Không";}?>
						</span>
					</p>
					<br style="line-height:5px;"/>
                    <p>

                        <label class="title">&nbsp;</label>
                        <span class="notes" style="color:#666666;font-size:0.8em;">
                            (Dạng tập tin: *.zip, *.rar, *.doc, *.odt, *.docx, *.pdf).
                        </span>
                        <br class="clearBoth"/> 
                    </p>
					<br style="line-height:5px;"/>
                    <p>
                        <label class="title">Quốc gia</label>
						
					<select id="txtQuocGia" name="txtQuocGia" style="width:122px;" onchange="ajaxSelect2Select('txtQuocGia','txtTinhThanh','<?=$root?>/loadTinhThanh.php','IdQuocGia');"> 
					<option value="-1">---Chọn---</option>
					<? 
						$rs = $db->query("SELECT * FROM ".$prefix."quocgia order by qg_id ASC");
						while($row = $db->fetch_array($rs)){
					?>
						<option value="<?=$row[qg_id]?>"><?=$row[qg_ten]?></option>
					<? } ?>
					</select>
					<script language="javascript">
					  var a = document.getElementById('txtQuocGia');
					 for(var i=0;i<a.length;i++)
					 {if(a[i].value=="<?=$td_quocgia?>")
					 {a.selectedIndex=i;break;}}
				 	 </script>
					<label class="labelLine">Tỉnh/TP</label>
			        <select id="txtTinhThanh" name="txtTinhThanh" style="width:122px;">
						<option value="-1">---Chọn---</option>

						  <?
						  if($IdQuocGia == ""){$IdQuocGia = $td_quocgia;}
						  if($IdQuocGia) 
			
						  {
			
							$sql="select * from ".$prefix."tinhthanh where tt_maquocgia = '".$IdQuocGia."' order by tt_id ASC";
							$rs = $db->query($sql);
			
							if($db->num_rows($rs))
			
							{
			
								while($rows=$db->fetch_array($rs))
			
								{
			
								?>
			
								<option value="<?=$rows["tt_id"]?>"><?=$rows["tt_ten"]?></option>
			
								<?
			
								}
			
							}
			
						}
			
						?>

					</select>
				<script language="javascript">
			  	 var a = document.getElementById('txtTinhThanh');
				 for(var i=0;i<a.length;i++)
				 {if(a[i].value=="<?=$td_tinhthanh?>")
				 {a.selectedIndex=i;break;}}
	  		   </script>
                    </p>
                                   
                </div>                
            </div>
            <div class="product-new-control" style="margin-left:80px;">

               <textarea id="elm2" name="td_chitiet" rows="15" cols="80" style="width: 80%"><?=$td_chitiet?></textarea>

            </div>
                         
        </div>
        <div class="clearBoth" style="text-align: center;">
            <input name="btnPreview" onclick="javascript: confirmDelete('action.php?act=del_sanpham&u_id=<?=$t_nguoidang?>&id=<?=$pid?>');" id="btnPreview" src="<?=$root?>/themes/images/home/btnXoa.jpg" value="Xem trước" type="image">
            <input name="btnSave" onclick="javascript: return submitForm();" id="btnSave" src="<?=$root?>/themes/images/form/button-pm-message.jpg" value="Đăng bán" type="image">
        </div>    
        <div style="color:#888888;font-size:10pt;">
            (*) Nên và không nên khi tuyển dụng, xem <a target="_blank" href="javascript:void(0);">tại đây</a>
        </div>
    </div>
    <div class="corner-round-02-bottom-right">
        <div class="corner-round-02-bottom-left">

            <div class="corner-round-02-bottom-bg"></div>
        </div>
    </div>   
</div>
<div style="height:10px"> </div>
<div id="uploadDiv"></div>       
    </div>
    <div style="clear:both;"></div>      
    <!-- } Main Page-Content -->  
	<input type="hidden" name="submit" id="submit" value="submit" />
</form>
                
      